$(function () {
    var jgd_id = $("#jgd_id").val();
    //表格初始加载
    $('#jgd_jgdmx_table').datagrid({
        url: $.webPath() + "/jggl/jgdgl/jgddetail_wzmx?mxzt=0&jgdId=" + jgd_id,
        toolbar: "#jgdmx_detail_toolbar",
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        pageNumber: 1,
        showFooter: true,
        fit: true,
        rownumbers: true,
        striped: true,
        columns: [
            [
                {field: 'id', title: 'ID', hidden: true},
                {field: 'khbm', title: '卡号编码', align: 'center', width: 80},
                {field: 'jtwz.code', title: '物资编码', align: 'center', width: 70},
                {field: 'jtwz.name', title: '物资名称', align: 'center', width: 50},
                {field: 'jtwz.ggxh', title: '规格型号', align: 'center', width: 70},
                {field: 'jtwz.dw', title: '单位', align: 'center', width: 50},
                {field: 'cd.z', title: '产地', align: 'center', width: 50},
                {field: 'ck.mc', title: '仓库', align: 'center', width: 50},
                {field: 'sku', title: '标识', align: 'center', width: 65},
                {field: 'sbsl', title: '申报数量', align: 'center', width: 40},
                {field: 'sbzl', title: '申报重量', align: 'center', width: 50},
                {field: 'jg_sbsl', title: '加工数量', align: 'center', width: 40},
                {field: 'jg_sbzl', title: '加工重量', align: 'center', width: 50,
                    formatter: function (value, row) {
                        if (value && value > 0 && row.id && row.id > 0) {
                            return  "<a title='点击查看详细'style='color:red;font-weight:bold;' href='javascript:ckd_detail(" + row.id + ");'>" + value.toFixed(4) + "</a>";
                        } else {
                            if (value > 0 && !row.id) {
                                return  value.toFixed(4);
                            } else {
                                return 0;
                            }

                        }
                    }
                }
            ]
        ]
    });
})

// 查看入库明细
function ckd_detail(jgdmxid) {
    var button
    button = [
    ];
    $.window({
        title: "出库单详细",
        iconCls: 'icon-tip',
        url: $.webPath() + "/jggl/jgdgl/ckd_detail?jgdmx_id=" + jgdmxid,
        width: 1024,
        height: 500,
        buttons: button
    });
}
